<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="Bookmark" href="favicon.ico">
    <link rel="Shortcut Icon" href="favicon.ico"/>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="lib/html5.js"></script>
    <script type="text/javascript" src="lib/respond.min.js"></script>
    <![endif]-->
    <script type="text/javascript" src="vue/Vue.v2.6.12.js"></script>
    <script type="text/javascript" src="js/HttpUtil.js"></script>
    <script type="text/javascript" src="js/admin.check.login.js"></script>
    <link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css"/>
    <!--[if IE 6]>
    <script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <!--/meta 作为公共模版分离出去-->

    <title>新增文章 - 资讯管理 - H-ui.admin v3.0</title>
    <meta name="keywords" content="H-ui.admin v3.0,H-ui网站后台模版,后台模版下载,后台管理系统模版,HTML后台模版下载">
    <meta name="description" content="H-ui.admin v3.0，是一款由国人开发的轻量级扁平化网站后台模板，完全免费开源的网站后台管理系统模版，适合中小型CMS后台系统。">
</head>
<body>
<article class="page-container">
    <!--@submit="checkForm"-->
    <!--action="http://localhost:8080//merchant_api_war_exploded/information/addInformation.do"-->
    <form class="form form-horizontal" action="http://localhost:80/merchant_api/information/upload"
          id="form-article-add" method="post" enctype="multipart/form-data"
          @submit.prevent="saveReport();">
        <!--        @submit="checkForm"-->
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>文章标题：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="{{title}}" placeholder="" v-model="title" id="title"
                       name="title">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">简略标题：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="{{simpleTitle}}" placeholder="" id="simpleTitle"
                       v-model="simpleTitle"
                       name="simpleTitle">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>分类栏目：</label>
            <div class="formControls col-xs-8 col-sm-9"> <span class="select-box">
				<select v-model="categoryId" name="categoryId" class="select">
					<option value="0">全部栏目</option>
					<option value="1">新闻资讯</option>
					<option value="2">├行业动态</option>
					<option value="3">├行业资讯</option>
					<option value="4">├行业新闻</option>
				</select>
				</span></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>文章类型：</label>
            <div class="formControls col-xs-8 col-sm-9"> <span class="select-box">
				<select name="" v-model="textType" class="select">
					<option value="0">全部类型</option>
					<option value="1">帮助说明</option>
					<option value="2">新闻资讯</option>
				</select>
				</span></div>
        </div>
        <!--        <div class="row cl">
                    <label class="form-label col-xs-4 col-sm-2">排序值：</label>
                    <div class="formControls col-xs-8 col-sm-9">
                        <input type="text" class="input-text" value="0" placeholder="" id="" name="">
                    </div>
                </div>-->
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">关键词：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="{{keyword}}" placeholder="" id="keyword" v-model="keyword"
                       name="">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">资讯内容：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <textarea name="" cols="" rows="" class="textarea" placeholder="说点什么...最少输入10个字符" datatype="*10-100"
                          dragonfly="true" nullmsg="备注不能为空！" v-model="optionalExcerpt"></textarea>
            </div>
        </div>
<!--        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">文章作者：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="{{authors}}" placeholder="" id="authors" v-model="authors"
                       name="">
            </div>
        </div>-->
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">文章来源：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="{{articleSource}}" placeholder="" id="articleSource"
                       v-model="articleSource" name="">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">允许评论：</label>
            <div class="formControls col-xs-8 col-sm-9 skin-minimal">
                <div class="check-box">
                    <input type="checkbox" id="checkbox-pinglun" v-model="reviewStatus">
                    <label for="checkbox-pinglun">&nbsp;</label>
                </div>
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">缩略图：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <div class="uploader-thum-container">
                    <!--                    <div id="fileList" class="uploader-list"></div>-->
                    <div><input type="file" name="file"/></div>
                    <div><input type="submit" name="submit" value="上传"/></div>
                    <!--                    <div id="filePicker">选择图片</div>-->
                    <!--                    <button id="btn-star" class="btn btn-default btn-uploadstar radius ml-10">开始上传</button>-->
                </div>
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
                <button type="button" class="btn btn-primary radius" @click="checkForm(2)"><i
                        class="Hui-iconfont">&#xe632;</i> 保存并提交审核
                </button>
                <button @click="checkForm(0);" class="btn btn-secondary radius" type="button"><i
                        class="Hui-iconfont">&#xe632;</i> 保存草稿
                </button>
                <button @click="removeIframe();" class="btn btn-default radius" type="button">
                    &nbsp;&nbsp;取消&nbsp;&nbsp;
                </button>
            </div>
        </div>
    </form>
</article>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.js"></script>
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.page.js"></script>
<!--/_footer /作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript" src="lib/webuploader/0.1.5/webuploader.min.js"></script>
<script type="text/javascript" src="lib/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript" src="lib/ueditor/1.4.3/ueditor.all.min.js"></script>
<script type="text/javascript" src="lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
    $(function () {
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });
        var ue = UE.getEditor('editor');
    });

    let vue = new Vue({
        el: '#form-article-add',
        data: {
            informationId: "",       //资讯id
            title: "",               //标题
            simpleTitle: "",         //简易标题
            categoryId: "",         //资讯分类栏目
            textType: "",            //文章类型
            keyword: "",            //关键词
            optionalExcerpt: "",            //文章摘要
            authors: "",            //文章作者
            articleSource: "",            //文章来源
            reviewStatus: "",            //评论状态
            content: "",            //文章内容
            urlImg: "",            //图片地址
            ids: 0,
            sourceId:"",            //作者Id
        },
        methods: {
            //submit
            saveReport: function () {
                let thisM = this;
                layer.msg("正在上传-------");
                $("#form-article-add").ajaxSubmit(function (en) {
                    if (en.code == "101"){
                        layer.msg("上传失败,文件大于1M");
                        return;
                    }
                    var parse = JSON.parse(en);
                    thisM.urlImg = parse.data;
                    layer.msg("上传成功");
                });
                return false; // 必须返回false，否则表单会自己再做一次提交操作，并且页面跳转
            },
            //提交
            checkForm: function (statu) {
                if (this.informationId == "") {
                    console.log("A");
                    console.log("informationId" + this.informationId);
                    let url = "information/addInformation.do";
                    let params = {
                        title: this.title,
                        simpleTitle: this.simpleTitle,
                        categoryId: this.categoryId,
                        textType: this.textType,
                        keyword: this.keyword,
                        optionalExcerpt: this.optionalExcerpt,
                        authors: this.authors,
                        articleSource: this.articleSource,
                        reviewStatus: this.reviewStatus,
                        content: this.content,
                        urlImg: this.urlImg,
                        statusType: statu,
                        sourceId:this.sourceId,
                    }
                    postWithJson(url, params, function (data) {
                        alert("提交成功！");
                        location.reload();
                    });
                } else {
                    console.log("B");
                    let url = "information/updateByInformationIdInformation.do";
                    let params = {
                        title: this.title,
                        simpleTitle: this.simpleTitle,
                        categoryId: this.categoryId,
                        textType: this.textType,
                        keyword: this.keyword,
                        optionalExcerpt: this.optionalExcerpt,
                        authors: this.authors,
                        articleSource: this.articleSource,
                        reviewStatus: this.reviewStatus,
                        content: this.content,
                        urlImg: this.urlImg,
                        informationId: this.informationId,
                        sourceId:this.sourceId,
                    }
                    postWithJson(url, params, function (data) {
                        layer.config("提交成功", function () {
                            location.replace(location);
                        })
                    });
                }

            },
            //显示
            showArticle: function () {
                let urlParam = getUrlParam("informationId");
                if (urlParam == null) {
                    return;
                }
                let url = "information/selectByIdInformation.do";
                let params = urlParam;
                let thisM = this;
                postWithJson(url, params, function (data) {
                    thisM.title = data.title;
                    thisM.simpleTitle = data.simpleTitle;
                    thisM.categoryId = data.categoryId;
                    thisM.textType = data.textType;
                    thisM.keyword = data.keyword;
                    thisM.optionalExcerpt = data.optionalExcerpt;
                    thisM.articleSource = data.articleSource;
                    thisM.authors = data.authors;
                    thisM.reviewStatus = data.reviewStatus;
                    thisM.content = data.content;
                    thisM.urlImg = data.urlImg;
                    thisM.informationId = data.informationId;
                })
            },
            removeIframe() {
                location.reload();
            },

            //cookie值
            cookieNumber: function () {
                let cookieNum = getCookie("Massage");
                console.log("Massage"+cookieNum)
                let user = JSON.parse(cookieNum);
                let userNameValue = user.managerName;
                let userNameId = user.managerId;
                this.authors = userNameValue;
                this.sourceId = userNameId;
            },

        },
        mounted: function () {
            this.cookieNumber();
            this.showArticle();
        }
    });
</script>
</body>
</html>